1 <?php
2     function validate_email($email) {
3         
if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
4             
return true;
5         }
6         
else {
7             
return "* Invalid Email";
8         }
9     }
10     function validate_name($name) {
11         
if(preg_match("/^[a-zA-Z ]{2,50}$/",$name)) {
12             
return true;
13         }
14         
else {
15             
return "* Invalid Name";
16         }
17     }
18     function validate_password($password) {
19         
if(strlen($password) > 4 && strlen($password) < 31) {
20             
return true;
21         }
22         
else {
23             
return "* Only 5-30 characters allowed";
24         }
25     }
26     function validate_phone($phone) {
27         
if(preg_match("/^[0-9]{10}$/",$phone)) {
28             
return true;
29         }
30         
else {
31             
return "* Invalid Phone Number";
32         }
33     }
34     function validate_number($number) {
35         
if(preg_match("/^[0-9]*$/",$number)) {
36             
return true;
37         }
38         
else {
39             
return "* Invalid number";
40         }
41     }
42     function validate_price($price) {
43         
if(preg_match("/^[0-9.]*$/",$price)) {
44             
return true;
45         }
46         
else {
47             
return "* Invalid Price";
48         }
49     }
50     function validate_username($username) {
51         
if(preg_match("/^[a-zA-Z0-9]{5,14}$/",$username)) {
52             
return true;
53         }
54         
else {
55             
return "* 5-14 characters, Only Alphabets & Numbers allowed";
56         }
57     }
58 ?>


Gõ tìm kiếm nhanh...